package com.xiaobaibai.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xiaobaibai.valid.AddGroup;
import com.xiaobaibai.valid.ListValue;
import com.xiaobaibai.valid.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiaobaibai
 * @since 2020-10-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("coupon")
@ApiModel(value="Coupon对象", description="")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class Coupon implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "优惠券id")
    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "新增不可指定id",groups = AddGroup.class)
    @NotNull(message = "修改需指定id",groups = UpdateGroup.class)
    private Integer id;

    @ApiModelProperty(value = "优惠券名称")
    @TableField("coupon_name")
    @NotNull(message = "请输入优惠券名称",groups = AddGroup.class)
    private String couponName;

    @ApiModelProperty(value = "类型:0满减(可满0减)2折扣")
    @TableField("coupon_type")
    @ListValue(values = {0,1})
    @NotNull(message = "请选择优惠券类型",groups = AddGroup.class)
    private Integer couponType;

    /**
     * Controller层手动根据类型校验
     */
    @ApiModelProperty(value = "优惠金额(对无门槛和满减有效)")
    @TableField("coupon_price")
    @Min(value = 0)
    private BigDecimal couponPrice;

    @ApiModelProperty(value = "使用门槛")
    @TableField("coupon_threshold")
    @NotNull(message = "请输入使用门槛",groups = AddGroup.class)
    @Min(value = 0)
    private Integer couponThreshold;

    @ApiModelProperty(value = "打几折(仅对折扣有效)")
    @TableField("coupon_discount")
    @Min(value = 0,message = "打折数据错误")
    @Max(value = 10,message = "打折数据错误")
    private BigDecimal couponDiscount;

    @ApiModelProperty(value = "优惠券数量")
    @TableField("coupon_count")
    @NotNull(message = "优惠券数量不可为空",groups = AddGroup.class)
    @Min(value = 0)
    private Integer couponCount;

    @ApiModelProperty(value = "优惠券已经领取的数量")
    @TableField("coupon_receive")
    private Integer couponReceive;

    @ApiModelProperty(value = "优惠券剩余数量")
    @TableField("coupon_remaining")
    private Integer couponRemaining;

    @ApiModelProperty(value = "优惠券创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "优惠券失效时间")
    @TableField("coupon_invalidation_time")
    @NotNull(message = "优惠券失效时间不可为空",groups = AddGroup.class)
    @Future(message = "必须是一个将来的时间",groups = AddGroup.class)
    private Date couponInvalidationTime;

    @ApiModelProperty(value = "优惠券状态(凌晨改变)")
    @TableField("coupon_status")
    private Boolean couponStatus;


}
